package simplefactory

import "fmt"

type LoggerType string

const (
	LoggerTypeConsole LoggerType = "console"
	LoggerTypeFile    LoggerType = "file"
)

// 日志接口
type Logger interface {
	Log(message string)
}

// 控制台日志记录
type ConsoleLogger struct {
}

func (c *ConsoleLogger) Log(message string) {
	fmt.Println("console log:", message)
}

// 文件日志记录
type FileLogger struct {
}

func (l *FileLogger) Log(message string) {
	fmt.Println("file log:", message)
}

// 日志工厂
func NewLogger(loggerType LoggerType) Logger {
	switch loggerType {
	case LoggerTypeConsole:
		return &ConsoleLogger{}
	case LoggerTypeFile:
		return &FileLogger{}
	default:
		return &ConsoleLogger{}
	}
}